LaTeXのDevcontainer featureを作る
モチベ
storage費用を無くしたい
既存のもの
なさそう
どうやって作るか
apt-getから入れる
versionが古い
2023-10-31 12:16:12 とりあえずできた
6.48 GB専有
optionでどれにするか変えられると便利そうだ
options
✅scheme
✅docfiles
✅srcfiles
collections
配列でstringを渡せないので、runtime checkをかける
スペース区切りでcollection namesを渡し、不正な文字列があればエラーを吐く
additional packages
どうせtlmgrを動かすのだから、そのとき弾けばいいか?
$ error_message=$(tlmgr install "$package" 2>&1)
↑を変換したコード
ライセンスは元のrepoに準拠したい
set -eをつけて、エラーが発生したら失敗するように書き換えるべき code:install.sh
# ConTeXt cache can be created on runtime and does not need to
# increase image size
export TEXLIVE_INSTALL_NO_CONTEXT_CACHE=1
# As we will not install regular documentation why would we want to
# install perl docs…
export NOPERLDOC=1
apt-get update
code:install.sh
# basic utilities for TeX Live installation
apt-get install -qy --no-install-recommends curl git unzip
# miscellaneous dependencies for TeX Live tools
apt-get install -qy --no-install-recommends make fontconfig perl default-jre libgetopt-long-descriptive-perl libdigest-perl-md5-perl libncurses6
apt-get install -qy --no-install-recommends libunicode-linebreak-perl libfile-homedir-perl libyaml-tiny-perl
apt-get install -qy --no-install-recommends ghostscript
apt-get install -qy --no-install-recommends libsm6
# for syntax highlighting
apt-get install -qy --no-install-recommends python3 python3-pygments
apt-get install -qy --no-install-recommends gnuplot-nox
rm -rf /var/lib/apt/lists/*
rm -rf /var/cache/apt/
# bad fix for python handling
ln -s /usr/bin/python3 /usr/bin/python
DOCFILES="${DOCFILES}"
SRCFILES="${SRCFILES}"
SCHEME="${SCHEME}"
# the mirror from which we will download TeX Live
TLMIRRORURL="rsync://rsync.dante.ctan.org/CTAN/systems/texlive/tlnet/"
# whether to create font and ConTeXt caches
GENERATE_CACHES="yes"
cd /tmp
code:install.sh
echo "download and install equivs file for dummy package"
sed -i "s/2022/9999/" texlive-local
# freeglut3 does not ship with debian testing, so we remove it because there
sed -i "/Depends: freeglut3/d" texlive-local
apt-get update
# Mark all texlive packages as installed. This enables installing
# latex-related packges in child images.
apt-get install -qy --no-install-recommends equivs
# at this point also install gpg and gpg-agent to allow tlmgr's
apt-get install -qy --no-install-recommends gpg gpg-agent
# we install using rsync so we need to have it installed
apt-get install -qy --no-install-recommends rsync
# we need to change into tl-equis to get it working
equivs-build texlive-local
dpkg -i texlive-local_9999.99999999-1_all.deb
-fはequivsを使ったinstall方法に載っているoption
とりあえずそのままにしておく
code:install.sh
apt-get install -qyf --no-install-recommends
# reverse the cd command from above and cleanup
rm -rf ./*texlive*
# save some space
apt-get remove -y --purge equivs
apt-get autoremove -qy --purge
cache削除のような操作
apt-get cleanで/var/cache/apt/は削除されるからいらないはずなのだが……
code:install.sh
rm -rf /var/lib/apt/lists/
apt-get clean
rm -rf /var/cache/apt/
code:install.sh
echo "Fetching installation from mirror $TLMIRRORURL"
rsync -a --stats "$TLMIRRORURL" texlive
cd texlive
# create installation profile for full scheme installation with
# the selected options
echo "Building with documentation: $DOCFILES"
echo "Building with sources: $SRCFILES"
echo "Building with scheme: $SCHEME"
code:install.sh
echo "selected_scheme scheme-$SCHEME" > install.profile
# … but disable documentation and source files when asked to stay slim
echo "tlpdbopt_install_docfiles 0" >> install.profile
echo "BUILD: Disabling documentation files"
fi
echo "tlpdbopt_install_srcfiles 0" >> install.profile
echo "BUILD: Disabling source files"
fi
code:install.sh
# furthermore we want our symlinks in the system binary folder to avoid
# fiddling around with the PATH
echo "tlpdbopt_autobackup 0" >> install.profile
echo "tlpdbopt_sys_bin /usr/bin" >> install.profile
# actually install TeX Live
./install-tl -profile install.profile
cd ..
rm -rf texlive
echo "Set PATH to $PATH"
$(find /usr/local/texlive -name tlmgr) path add
sed -i '/package.loaded\"data-ini"\/a if os.selfpath then environment.ownbin=lfs.symlinktarget(os.selfpath..io.fileseparator..os.selfname);environment.ownpath=environment.ownbin:match("^.*"..io.fileseparator) else environment.ownpath=kpse.new("luatex"):var_value("SELFAUTOLOC");environment.ownbin=environment.ownpath..io.fileseparator..(arg-2 or arg-1 or arg0 or "luatex"):match("^"..io.fileseparator.."*$") end' /usr/bin/mtxrun.lua # pregenerate caches as per #3; overhead is < 5 MB which does not really # matter for images in the sizes of GBs; some TL schemes might not have
# all the tools, therefore failure is allowed
echo "Generating caches and ConTeXt files"
(luaotfload-tool -u || true)
# also generate fontconfig cache as per #18 which is approx. 20 MB but # benefits XeLaTeX user to load fonts from the TL tree by font name
cp "$(find /usr/local/texlive -name texlive-fontconfig.conf)" /etc/fonts/conf.d/09-texlive-fonts.conf
fc-cache -fsv
mtxrun --generate
texlua /usr/bin/mtxrun.lua --luatex --generate
context --make
context --luatex --make
fi
else
echo "Not generating caches or ConTeXt files"
fi
# test the installation; we only test the full installation because
# in that, all tools are present and have to work
latex --version
printf '\n'
biber --version
printf '\n'
xindy --version
printf '\n'
arara --version
printf '\n'
context --version
printf '\n'
context --luatex --version
printf '\n'
fi
python --version
printf '\n'
pygmentize -V
printf '\n'